package com.dmxh.service.impl;

import com.dmxh.mapper.TbAdminMapper;
import com.dmxh.pojo.TbAdmin;
import com.dmxh.pojo.TbAdminExample;
import com.dmxh.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private TbAdminMapper tbAdminMapper;

    @Override
    public TbAdmin queryByName(String username) {
        TbAdminExample tbAdminExample = new TbAdminExample();
        tbAdminExample.createCriteria().andUsernameEqualTo(username);
        List<TbAdmin> tbAdmins = tbAdminMapper.selectByExample(tbAdminExample);
        if (tbAdmins.size() > 0) {
            return tbAdmins.get(0);
        } else {
            return null;
        }
    }
}
